package comjimven.retrofit;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import comjimven.retrofit.bean.TestModel;
import comjimven.retrofit.interfaces.APIInterface;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.GsonConverterFactory;
import retrofit2.Response;
import retrofit2.Retrofit;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        new Thread(new Runnable() {
            @Override
            public void run() {
                Retrofit retrofit = new Retrofit.Builder()
                        .baseUrl("https://api.github.com")
                        .addConverterFactory(GsonConverterFactory.create())
                        .build();
                APIInterface service = retrofit.create(APIInterface.class);
                Call<TestModel> model = service.repo("Guolei1130");
                model.enqueue(new Callback<TestModel>() {
                    @Override
                    public void onResponse(Call<TestModel> call, Response<TestModel> response) {
                        TestModel body = response.body();
                        //   String bio = response.body().getBio();
                       System.out.println(body);
                    }

                    @Override
                    public void onFailure(Call<TestModel> call, Throwable t) {

                    }
                });

            }
        }).start();


    }
}
